package org.example.spring.domain;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.util.Date;

/**
 * @author Tang
 * @classname UserEntity
 * @description [  ]
 * @date 2023/5/2 12:59
 */
@Document(indexName = "users")
@Data
public class UserEntity implements Serializable {

    @Id
    private Integer id;

    @Field(name = "title",analyzer = "standard",type = FieldType.Keyword)
    private String title;

    @Field(name = "name",analyzer = "ik_max_word",type = FieldType.Text)
    private String name;

    @Field(name = "age",type = FieldType.Integer)
    private Integer age;

    @Field(name = "age",type = FieldType.Date,format = DateFormat.custom,pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone ="GMT+8")
    private Date birth;

}
